package ca.etsmtl.log730.projet.controller.server;

import java.util.HashMap;
import java.util.Map;
import java.util.Set;
import java.util.UUID;

import ca.etsmtl.log730.projet.controller.IWorkspaceManager;
import ca.etsmtl.log730.projet.model.user.User;
import ca.etsmtl.log730.projet.model.workspace.TextObject;

public class WorkspaceManager implements IWorkspaceManager {

	private Map<UUID, User> users = new HashMap<UUID, User>();
	protected Map<UUID, TextObject> objects = new HashMap<UUID, TextObject>();


	public Map<UUID, TextObject> getObjects() {
		return objects;
	}
	public Map<UUID, User> getUsers() {
		return users;
	}

	
	/*object*/
	public boolean addObject(TextObject to) {
		return (objects.put(UUID.randomUUID(), to) != null);
	}

	public boolean removeObject(UUID id) {
		return (objects.remove(id) != null);
	}
	
	
	
	
	public WorkspaceManager() {
	}
	
	
	
	
	public Set<UUID> getList() {
		return objects.keySet();
	}
	
	
	public User getUser(UUID id) {
		return users.get(id);
	}
	public void addUser(UUID id, User u) {
		users.put(id,u);
		
		System.out.println(users.size());
	}
	public void removeUser(UUID id) {
		users.remove(id);
	}
}
